import time

from nicegui import ui
from 考试系统.数据交互层 import logdir
from 考试系统.数据交互层 import GLOBA

def username_change(e):
    global username
    username=e.value

def password_change(e):
    global password
    password=e.value

def is_phone():
    return True


def yanzhengma_ok():
    return True


def pass_geshi_ok():
    return True


@ui.page('/忘记密码')
def forgetPasword():
    GLOBA.image()
    with ui.card().classes("absolute top-1/4 inset-x-1/3 w-1/3 rounded bg-slate-300 shadow-2xl bg-white opacity-80"):
        with ui.stepper().props('vertical').classes() as stepper:
            with ui.step('请输入手机号'):
                usrenamein = ui.input('输入手机号', on_change=lambda e: username_change(e))
                with ui.stepper_navigation():
                    ui.button('Next', on_click=lambda :stepper.next() if is_phone() else ui.notify('手机号不存在'))
            with ui.step('请输入验证码'):
                ui.input("请输入验证码")
                with ui.stepper_navigation():
                    ui.button('Next', on_click=lambda : stepper.next() if yanzhengma_ok() else ui.notify("验证码不正确"))
                    ui.button('Back', on_click=stepper.previous).props('flat')
            with ui.step('请输入密码'):
                ui.input('输入密码', on_change=lambda e: password_change(e))
                with ui.stepper_navigation():
                    ui.button('Fine', on_click=lambda: {ui.notify('修改密码成功')} if pass_geshi_ok() else ui.notify("密码格式不正确"))
                    ui.button('Back', on_click=stepper.previous).props('flat')


        with ui.row().style("flex-direction:row;width:100%;gap:0rem"):
            ui.button('返回', on_click=lambda: ui.open('/')).style("align-self:flex-start;width:100%").tailwind(
                'mx-10 my-3')

if __name__ == '__main__':
    ui.open('/忘记密码')